<?php 
include TMPL_PATH.'public/header.phtml';
?>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/jscal2.css"/>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/border-radius.css"/>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/win2k.css"/>
<script type="text/javascript" src="/statics/js/calendar/calendar.js"></script>
<script type="text/javascript" src="/statics/js/calendar/lang/zh-cn.js"></script>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <a href='<?php echo U('order/order_list');?>'><em>订单列表</em></a><span>|</span>
        <a href='javascript:;' class="on" ><em>批量打印快递单</em></a><span>|</span><a href="<?php echo U('order/order_express_product_list');?>">编辑快递单商品</a></div>
</div>
<form action="__SELF__" method="post" id="theForm" name="theForm" onsubmit="return validate();">
<div class="pad-10">
<div class="col-tab">
<div class="contentList pad-10">
  <div id="listDiv" class="list-div">

<table cellspacing="1" cellpadding="3"  width="100%"  class="table_form">
  <tbody>
  <tr>
    <td style="background-color: rgb(255, 255, 255);">配送方式</td>
    <td style="background-color: rgb(255, 255, 255);">
    <select id="shipping_id" name="shipping_id">
        <option value="0">请选择...</option>
        <?php 
        if(isset($shippingList) && $shippingList):
        	foreach ($shippingList as $shipping):
        ?>
        <option value="<?php echo $shipping['id']?>"><?php echo $shipping['name'];?></option>
        <?php 
        	endforeach;
        endif;
        ?>
     </select>&nbsp;&nbsp;&nbsp;
				开始时间 (从0时0分0秒)<input type="text" value="<?php echo date('Y-m-d');?>" class="input-text" name="start_time" id="start_time">&nbsp;&nbsp;&nbsp;
				<script type="text/javascript">
			Calendar.setup({
			weekNumbers: false,
		    inputField : "start_time",
		    trigger    : "start_time",
		    dateFormat: "%Y-%m-%d",
		    showTime: false,
		    minuteStep: 1,
		    onSelect   : function() {this.hide();}
			});
        </script>
				截止时间 (到23时59分59秒) <input type="text" value="<?php echo date('Y-m-d');?>" class="input-text" name="end_time" id="end_time">
				<script type="text/javascript">
			Calendar.setup({
			weekNumbers: false,
		    inputField : "end_time",
		    trigger    : "end_time",
		    dateFormat: "%Y-%m-%d",
		    showTime: false,
		    minuteStep: 1,
		    onSelect   : function() {this.hide();}
			});
        </script>
    </td>
  </tr>
 <tr>
  <td style="background-color: rgb(255, 255, 255);">可选商品</td>
    <td style="background-color: rgb(255, 255, 255);">
	<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
        
       
        <!-- 商品列表 -->
       
        <tbody><tr>
          <td width="42%" style="background-color: rgb(255, 255, 255);"><select ondblclick="addItem(this)" style="width:100%;height:300px;" size="20" id="source_select" name="source_select">
		  		   <?php 
		  		   if($productList):
		  		   		foreach ($productList as $pid => $product):
		  		   ?>
		  		   <option value="<?php echo $pid?>"><?php echo $product['name'];?></option>
		  		   <?php 
		  		   		endforeach;
		  		   	endif;
		  		   ?>
		              </select>          </td>
          <td align="center" style="background-color: rgb(255, 255, 255);"><p>
              <input type="button" value="&gt;&gt;" onclick="addAllItem(document.getElementById('source_select'))" class="button" name="button">
            </p>
            <p>
              <input type="button" value="&gt;" onclick="addItem(document.getElementById('source_select'))" class="button" name="button">
            </p>
            <p>
              <input type="button" value="&lt;" onclick="removeItem(document.getElementById('target_select'),false)" class="button" name="button">
            </p>
            <p>
              <input type="button" onclick="removeItem(document.getElementById('target_select'), true)" value="&lt;&lt;" class="button" name="button">
            </p></td>
          <td width="42%" style="background-color: rgb(255, 255, 255);"><select multiple="multiple" style="width:100%;height:300px" size="20" id="target_select" name="target_select[]">
		  
            </select>          </td>
        </tr>
      </tbody></table>
	</td>
  
  </tr>
</tbody></table>

<!--<input type="hidden" value="print" name="downship">-->
<center><input  name="dosubmit" type="submit" class="button" value="打印快递单"></center>
<!--<center><input type="submit" value="打印快递单" class="button" onclick="this.form.target = '_blank'"/></center> -->
<input type="hidden" value="" id="goods_data" name="goods_data">
</div>
</div>

<div class="bk15"></div>
</div>
</div>
</form>
</body>
</html>
<script language="JavaScript">
<!--
function validate()
{
      if (document.forms['theForm'].elements['shipping_id'].value == 0)
      {
          alert('请选择配送方式');
          return false;
      }

	var spec_arr = new Array();
    var objs = document.forms['theForm'].elements["target_select"];
	for (i=0; i< objs.length; i++)
    {
	    spec_arr[i] = objs[i].value;
    }
	document.getElementById("goods_data").value = spec_arr.join(",");

	if (document.forms['theForm'].elements['goods_data'].value == 0)
      {
          alert('请选择商品');
          return false;
      }
	return true;
}


function clearOptions(id)
{
  var obj = document.getElementById(id);
  while(obj.options.length>0)
  {
    obj.remove(0);
  }
}

function addAllItem(sender)
{
  if(sender.options.length == 0) return false;
  for (var i = 0; i < sender.options.length; i++)
  {
    var opt = sender.options[i];
    addItem(null, opt.value, opt.text);
  }
}

function addItem(sender, value, text)
{
  var target_select = document.getElementById("target_select");
  
  var newOpt   = document.createElement("OPTION");
  if (sender != null)
  {
    if(sender.options.length == 0) return false;
    var option = sender.options[sender.selectedIndex];
    newOpt.value = option.value;
    newOpt.text  = option.text;
  }
  else
  {
    newOpt.value = value;
    newOpt.text  = text;
  }
  if (targetItemExist(newOpt)) return false;
  if (target_select.length>=50)
  {
    alert(item_upper_limit);
  }
  target_select.options.add(newOpt);
 
}

// 商品是否存在
function targetItemExist(opt)
{
  var options = document.getElementById("target_select").options;
  for ( var i = 0; i < options.length; i++)
  {
    if(options[i].text == opt.text && options[i].value == opt.value) 
    {
      return true;
    }
  }
  return false;
}
function removeItem(sender,isAll)
{
  if (!isAll)
  {
    var goodsName = sender.options[sender.selectedIndex].text;
    for (var i = 0; i < sender.options.length;)
    {
      if (sender.options[i].selected) {
        sender.remove(i);
      }
       else
      {
        i++;
      }
    }
  }
  else
  {
    sender.innerHTML = "";
  }
}

//-->
</script>